import 'package:eleapp/util/theme_util.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

// 引入路由文件
import './routers/routers.dart';
// 引入控制器Binding
import './controller/binding.dart';
import './init.dart';
import './language/language.dart';
import './util/locale_util.dart';
import './pages/settings/customtheme.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await InitClass.startInit();

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        FocusManager.instance.primaryFocus?.unfocus();
      },
      child: GetMaterialApp(
        debugShowCheckedModeBanner: false,
        title: '教师评分App',
        initialBinding: AllControllerBinding(),
        // theme: ThemeData(
        //   primarySwatch: Colors.blue,
        //   appBarTheme: const AppBarTheme(centerTitle: true),
        // ),
        theme: lightTheme,
        darkTheme: darkTheme,
        themeMode: ThemeOptions.gethemeDefault(context),

        // 初次加载路由
        initialRoute: '/',
        // onGenerateRoute: onGenerateRoute,

        // 默认路由切换动画
        defaultTransition: Transition.rightToLeft,
        // getx管理路由
        getPages: AppPage.appPage,
        // 国际化配置
        translations: Messages(),
        locale: LocaleOptions.getDefault(),
        // locale: const Locale("zh", "CN"),
        // 未匹配到语言包后默认使用的语言
        fallbackLocale: const Locale("zh", "CN"),
      ),
    );
  }
}
